#include "base/threadsafe_vector.h"
#include <iostream>
#include <thread>

ThreadSafe_Vector<int> tv;

void add_n_element(int n) {
    for (int i = 0; i < n; i++) {
        tv.Append(i);
    }
}

int main() {
    tv.Append(1);
    std::cout << tv.Size() << std::endl;

    std::vector<std::thread> threads;
    for (int i = 0; i < 4; i++) {
        threads.emplace_back(add_n_element, 1000000);
    }
    for (int i = 0; i < 4; i++) {
        threads[i].join();
    }
    std::cout << tv.Size() << std::endl;
    std::cout << tv.RandomItem() << std::endl;

    ThreadSafe_Vector<int> tt;
    tt.Append(tv);
    std::cout << tt.Size() << std::endl;

    tt.Remove(0);
    std::cout << tt.Size() << std::endl;

    ThreadSafe_Vector<int> t{1, 2, 3};
    std::cout << t.Size() << std::endl;

    ThreadSafe_Vector<int> p(3, 1);
    p.Assign(1, 2);
    p.Assign(2, 3);
    std::cout << p.Get(0) << '-' << p.Get(1) << '-' << p.Get(2) << std::endl;

    return 0;
}